<template>
  <div>
    <!-- <div style="padding-left:225px;padding-top:20px ;">
      <VolForm :formFileds="formFileds" :formRules="formRules"> </VolForm>
    </div> -->

    <iframe
      id="myiframe"
      scrolling="no"
      frameborder="0"
      width="100%"
      height="1000"
      :src="fileURL"
    ></iframe>
  </div>
</template>

<script>
import VolForm from "@/components/basic/VolForm.vue";
export default {
  components: {
    VolForm
  },
  data() {
    return {
      // fileURL: `https://fineapi.boss.i-town.cn/webroot/decision/view/report?viewlet=WorkBook2.cpt&fine_username=${this.userName}&merchantCode={this.merchantCode}`,
      fileURL: "",
      fileName: "test.pdf",
      formFileds: {
        type: "",
        supplierName: ""
      },
      formRules: [
        [
          {
            title: "类型",
            field: "type",
            type: "text"
          },
          {
            title: "供应商名称",
            field: "supplierName",
            type: "text"
          },
          {
            render: (h, {}) => {
              return h(
                "button",
                {
                  class: "ivu-btn",
                  style: {
                    "margin-left": "10px"
                  },
                  on: {
                    click: () => {
                      this.searchUseinfo();
                    }
                  }
                },
                "查询"
              );
            },
            colSize: 1
          },
          {
            render: (h, {}) => {
              return h(
                "button",
                {
                  class: "ivu-btn",
                  style: {
                    "margin-left": "10px"
                  },
                  on: {
                    click: () => {
                      let fileURL = this.fileURL;
                      let fileName = this.fileName;
                      this.downloadPdf(fileURL, fileName);
                    }
                  }
                },
                "下载"
              );
            },
            colSize: 1
          }
        ]
      ],
      merchantCode: "",
      userName: ""
    };
  },
  created() {
    let userTypeInfo = JSON.parse(sessionStorage.getItem("sessionStorageUSER"));
    this.userName = userTypeInfo.itownuserName;
    this.merchantCode = userTypeInfo.merchantCode;
    // this.fileURL = `https://fineapi.boss.i-town.cn/webroot/decision/view/report?viewlet=WorkBook2.cpt&fine_username=${this.userName}`;
    this.fileURL ="https://fineapi.boss.i-town.cn/smartbi/vision/share.jsp?resid=I8a809939018aac0aac0a802e018ad5cfb55209e4"
    // console.log(
    //   this.userName,
    //   this.merchantCode,
    //   " console.log(  this.userName)"
    // &&merchantCode=${this.merchantCode}
    // );
  },
  methods: {
    // searchUseinfo() {
    //   // this.fileURL = `http://192.168.1.29:37799/webroot/decision/link/kaKn?type=${this.formFileds.type}&&supplierName=${this.formFileds.supplierName}`;
    //      this.fileURL=`http://192.168.1.29:8075/webroot/decision/view/report?viewlet=WorkBook1.cpt`
    // },
    downloadPdf(fileURL, fileName) {
      var link = document.createElement("a");
      link.href = fileURL;
      link.download = fileName;
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
    }
  }
};
</script>

<style></style>
